package com.jiangli.controller.admin;

import com.jiangli.annotation.Log;
import com.jiangli.dto.FeedbackQureyDTO;
import com.jiangli.entity.Feedback;
import com.jiangli.result.PageResult;
import com.jiangli.result.Result;
import com.jiangli.service.FeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.springframework.web.bind.annotation.*;

@RestController("AdminFeedbackController")
@RequestMapping("/admin/feedback")
@Slf4j
@Api(tags = "管理端反馈")
public class FeedbackController {
    private final FeedbackService feedbackService;
    public FeedbackController(FeedbackService feedbackService) {
        this.feedbackService = feedbackService;
    }

    @GetMapping
    @ApiOperation("获取反馈信息")
    public Result<PageResult> getFeedback(FeedbackQureyDTO feedbackQureyDTO) {
        PageResult pageResult = feedbackService.get(feedbackQureyDTO);
        return Result.success(pageResult);
    }
    @PostMapping
    @ApiOperation("修改用户反馈接口")
    @Log("修改用户反馈")
    public Result<String> reviseFeedback(@RequestParam Long feedbackId, @RequestParam int status) {
        try{feedbackService.reviseFeedback(feedbackId,status);
        return Result.success("修改成功");}
        catch (Exception e)
        {
            return Result.error(e.getMessage());
        }
    }
    @DeleteMapping
    @ApiOperation("删除反馈")
    @Log("删除反馈")
    public Result<String> deleteFeedback(@RequestParam Long feedbackId) {
        try{
            feedbackService.deleteFeedback(feedbackId);
            return Result.success("删除成功");
        }
        catch (Exception e)
        {
            return Result.error(e.getMessage());
        }
    }
}
